// RandApp.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "RandApp.h"
#include <conio.h>

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// The one and only application object

#define SOFTWARE_VERSION	"v0.00.001"

CWinApp theApp;

using namespace std;

uint32 rand32()
{
	uint32 r = rand() & 0xFF;
	for(int i=0; i<3; i++)
	{
		r <<= 8;
		r |= rand() & 0xFF;
	}
	return r;
}

uint64 rand64()
{
	uint64 r = rand() & 0xFF;
	for(int i=0; i<7; i++)
	{
		r <<= 8;
		r |= rand() & 0xFF;
	}
	return r;
}

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
	int nRetCode = 0;

	// initialize MFC and print and error on failure
	if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
	{
		// TODO: change error code to suit your needs
		cerr << _T("Fatal Error: MFC initialization failed") << endl;
		nRetCode = 1;
	}
	else
	{
		// TODO: code your application's behavior here.
		CString strHello;
		strHello.LoadString(IDS_HELLO);
		cout << (LPCTSTR)strHello << endl;
	}
	cout << "RAND_MAX:" << RAND_MAX << endl;

	int i,r;
	uint32 r32;
	uint64 r64;
	char str[128];
	for(i=0; i<10; i++)
	{
		r = rand();
		r32 = rand32();
		r64 = rand64();
		sprintf(str, "i:%d, r:%X/%d, r32:%X/%u, r64:%I64X/%I64u\n", i, r, r, r32, r32, r64, r64);
		cout << str;
	}
	cout << endl;
	srand((unsigned int)time(NULL));
	for(i=0; i<10; i++)
	{
		r = rand();
		r32 = rand32();
		r64 = rand64();
		sprintf(str, "i:%d, r:%X/%d, r32:%X/%u, r64:%I64X/%I64u\n", i, r, r, r32, r32, r64, r64);
		cout << str;
	}
	cout << endl << "Software Version: " << SOFTWARE_VERSION << endl;
	_getch();

	return nRetCode;
}


